const express = require('express')
const auth = require('../controller/auth')

const router = express.Router()
router.use((req, res, next) => {
    let id = req.cookies['user']
    let sid = req.cookies['connect.sid']
    if (id) {
        console.log("用户id: ", id)
        next()
    }
    if (sid) {
        console.log("连接ID: ", sid)
    }
    return

})
router.get('/', (req, res) => {
    const username = req.query.username
    const password = req.query.password
    if (username === '' && password === ''){
        if(auth.getLogin(username, password)){

        }
        console.log('不存在cookie')

    } else {
        console.log(typeof(req.cookies))
        console.log('存在cookie')
        console.log(req.cookies)
    }
    
    res.cookie("user","zhangsan",{httpOnly:true})
    res.end("ok")
})

router.get('/submit', (req, res) => {

})

module.exports = router